package com.snake.springboot.custom.service.assemble.base;


import com.snake.springboot.custom.api.model.base.CustRoleAuthModel;
import com.snake.springboot.custom.api.request.base.CustRoleAuthReq;
import com.snake.springboot.custom.api.request.base.StrategyReq;
import com.snake.springboot.custom.dao.mybatis.entity.base.CustRoleAuthDO;
import org.snake.common.utils.ListUtils;
import org.snake.common.utils.PropertyUtils;

import java.util.ArrayList;
import java.util.List;

/**
 * <p>角色权限组装器
 * 类{@code CustRoleAuthAssemble} </br>
 * 创建时间2025/2/10 17:59
 * @author yangxt
 * @see
 */
public class CustRoleAuthAssemble {

    public static List<CustRoleAuthDO> roleAuthDOListAss(CustRoleAuthReq  req) {
        List<StrategyReq> strategyList = req.getStrategyList();
        if (ListUtils.isEmpty(strategyList)){
            return null;
        }
        List<CustRoleAuthDO> list = new ArrayList<>(strategyList.size());
        for (StrategyReq strategy : strategyList) {
            CustRoleAuthDO roleAuthDO = new CustRoleAuthDO();
            roleAuthDO.setStrategyId(strategy.getStrategyId());
            roleAuthDO.setStrategyName(strategy.getStrategyName());
            roleAuthDO.setCustRoleId(req.getCustRoleId());
            roleAuthDO.setCustomId(req.getCustomId());
            roleAuthDO.setSystemId(strategy.getSystemId());
            roleAuthDO.setSystemName(strategy.getSystemName());
            list.add(roleAuthDO);
        }
        return list;
    }

    public static CustRoleAuthDO roleAuthDO(CustRoleAuthModel model) {
        CustRoleAuthDO authDO = new CustRoleAuthDO();
        PropertyUtils.copyProperties(authDO,model);
        return authDO;
    }
}
